<?php

/**
 * @Author: liu
 * @Date:   2017-11-01 15:41:03
 * @Last Modified by:   liu
 * @Last Modified time: 2017-11-01 16:16:25
 */

class OrderSmyFilling extends Eloquent
{
    protected $table = "order_smy_filling";

  
  	/**
  	 * @Author   lyt                      <ahlyt@anhuibj.com>
  	 * @DateTime 2017-11-01T15:42:59+0800
  	 * @param    [int]                   $shop_id            [门店id]
  	 * @param    [int]                   $item_id            [标准耗材id]
  	 * @param    [String]                $product_type       [产品包类型]
  	 * @param    [int]                   $product_item_id    [产品详情id]
  	 * @param    [String]                $order_id           [订单号]
  	 * @return   [无]                                       [无返回值]
  	 * 该方法只负责创建当天的 加注编码和记录的生成不负责相关的其他操作
  	 */
    public static function saveosf($shop_id,$item_id,$product_type,$product_item_id,$order_id){
    	$wn=date("w")==0?7:date("w");
    	$count=OrderSmyFilling::where("shop_id",$shop_id)->where("created_date",date("Y-m-d",time()))->count();
    	$code=$wn.sprintf("%03d",$count);
    	$osf=new OrderSmyFilling;
    	$osf->shop_id=$shop_id;
    	$osf->status=1;
    	$osf->item_id=$item_id;
    	$osf->product_type=$product_type;
    	$osf->product_item_id=$product_item_id;
    	$osf->order_id=$order_id;
    	$osf->filling_date=date("Y-m-d",time());
    	$osf->created_date=date("Y-m-d",time());
    	$osf->code=$code;
    	$osf->save();  		  	
    }
}